package com.ctu.study
{
	import flash.text.engine.*;
	
	import mx.core.UIComponent;
	public class ElementFormat_cloneExample extends UIComponent
	{
		private var ef1:ElementFormat;
        private var ef2:ElementFormat;
        
        [Embed(source="assets/ACaslonPro-Regular.otf", fontFamily="ACaslonProRegularEmbedded", mimeType="application/x-font", cff="true")]
		private const ACaslonProRegularEmbeddedFont:Class;
                    

        public function ElementFormat_cloneExample():void {
            var fd:FontDescription = new FontDescription();
            fd.fontLookup = flash.text.engine.FontLookup.DEVICE;
            //fd.fontLookup = flash.text.engine.FontLookup.EMBEDDED_CFF;
            //fd.renderingMode = flash.text.engine.RenderingMode.CFF;
            fd.fontName = "Trebuchet MS";
            fd.renderingMode = flash.text.engine.RenderingMode.CFF;
            //fd.fontName = "Arial";
            //fd =  ACaslonProRegularEmbeddedFont as FontDescription;

            var ef1:ElementFormat = new ElementFormat(fd);
            ef1.fontSize=20;
            
            
            var str:String = "This is flash text 0123456789";
            var tb:TextBlock = new TextBlock();
            var te1:TextElement = new TextElement(str, ef1);
            tb.content = te1;
            var line1:TextLine = tb.createTextLine(null, 600);
            trace("line1 dumped:"+line1.dump());
            addChild(line1);
            trace("is locked:"+ef1.locked);
            
            ef2 = (ef1.locked) ? ef1.clone() : ef1;    
            ef2.fontSize = 32;

            tb.content.elementFormat=ef2;
            var line2:TextLine = tb.createTextLine(null, 600);
            line2.y = 50;
            trace("line2 dumped:"+line2.dump());
            addChild(line2);
            
        }


	}
}